﻿
using System.Collections.ObjectModel;

using OpenCvSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;
using System.Linq;
namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 绘制方框
    /// </summary>
    [Filter("绘制方框",FilterType.Draw)]
    public class DrawRectangle : FilterBase
    {
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("位置1")]
        public CVPoint Point1 { get; set; } = new CVPoint();
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("位置2")]
        public CVPoint Point2 { get; set; } = new CVPoint();
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("颜色")]
        public Scalar Color { get; set; }
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("粗细", ParameterType.Optional)]
        public int Thickness { get; set; } = 1;
        /// <summary>
        /// 线段类型
        /// </summary>
        [InputParameter("线段类型", ParameterType.Optional)]
        public LineTypes LineType { get; set; } = LineTypes.Link8;
        /// <summary>
        /// 偏移量
        /// </summary>
        [InputParameter("缩放值", ParameterType.Optional)]
        public int Shift { get; set; } = 0;
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Cv2.Rectangle(mat,Point1,Point2,Color,Thickness,LineType,Shift);
            return ResultData<Mat>.Accept(TextResource.draw_success, mat);
        }
    }
}
